package 多线程.SemaphoreDemo;


/**
 * @author : K k
 * @date : 21:04 2020/9/14
 */
public class SemaphoreThread extends Thread{

    private SemaphoreService service;

    public SemaphoreThread(String name, SemaphoreService service) {
        super();
        this.setName(name);
        this.service = service;
    }

    @Override
    public void run() {
        this.service.doSomething();
    }

    public static void main(String[] args) {
        SemaphoreService semaphoreService=new SemaphoreService();
        for (int i=0;i<10;i++){
            SemaphoreThread thread=new SemaphoreThread("线程："+(i+1),semaphoreService);
            thread.start();
            System.out.println(semaphoreService.getChannel());
        }
    }

}
